{% extends "layouts/default.html.twig" %}

{% block title %}{{ 'Settings'|trans }}{% endblock %}

{% block body %}
    <div class="container-fluid">

        {{ include('partials/_page_header.html.twig', {header: 'Settings'|trans, description: 'General settings'|trans }) }}

        <div class="row">
            <div class="col-3">
                <ul class="nav nav-tabs flex-column">
                    <li class="nav-item">
                        <a class="nav-link active" data-bs-toggle="tab" aria-current="page" href="#general">General
                            settings</a>
                    </li>
                    {% if enable_users_auth != false %}
                        <li class="nav-item">
                            <a class="nav-link" href="#users" data-bs-toggle="tab">Users</a>
                        </li>
                    {% endif %}
                </ul>
            </div>

            <div class="col-8">
                <!-- Tab panes -->
                <div class="tab-content">
                    <div class="tab-pane container active" id="general"><h3>General settings</h3>

                        <br/>

                        <form>
                            <h4 class="mt-4">Date & time format</h4>

                            <div class="mb-3">
                                <label class="form-label" for="config_datetime_format">Date / Time
                                    format</label>
                                <input type="text" class="form-control" id="config_datetime_format"
                                       value="{{ config_datetime_format }}" disabled>
                            </div>

                            <div class="mb-3">
                                <label class="form-label" for="config_datetime_format_short">Date / Time format
                                    (short)</label>
                                <input type="text" class="form-control" id="config_datetime_format_short"
                                       value="{{ config_datetime_format_short }}" disabled>
                            </div>

                            <h4 class="mt-4">Translations</h4>

                            <div class="mb-3">
                                <label class="form-label" for="config_language">Language</label>

                                <input type="text" class="form-control" id="config_language"
                                       value="{{ config_language }}" disabled>
                            </div>

                            <h4 class="mt-4">Options</h4>

                            <div class="mb-3">
                                <div class="form-check form-switch">
                                    <input class="form-check-input" type="checkbox" role="switch"
                                           id="config_show_inactive_clients" {{ config_show_inactive_clients }}
                                           disabled>
                                    <label class="form-check-label" for="config_show_inactive_clients">Show inactive
                                        clients</label>
                                </div>
                            </div>

                            <div class="mb-3">
                                <div class="form-check form-switch">
                                    <input class="form-check-input" type="checkbox" role="switch"
                                           id="config_hide_empty_pools" {{ config_hide_empty_pools }} disabled>
                                    <label class="form-check-label" for="config_hide_empty_pools">Hide empty
                                        pools</label>
                                </div>
                            </div>

                            <h4>Authentication</h4>

                            <div class="mb-3">
                                <div class="form-check form-switch">
                                    <input class="form-check-input" type="checkbox" role="switch"
                                           id="config_enable_users_auth" {{ config_enable_users_auth }} disabled>
                                    <label class="form-check-label" for="config_enable_users_auth">Users
                                        authentication</label>
                                </div>
                            </div>

                            <div class="mb-3">
                                <div class="form-check form-switch">
                                    <input class="form-check-input" type="checkbox" role="switch"
                                           id="config-debug" {{ config_debug }} disabled>
                                    <label class="form-check-label" for="config-debug">Debug mode</label>
                                </div>
                            </div>

                            <h4 class="mt-4">Web app path</h4>

                            <div class="mb-3">
                                <label class="form-label" for="config_basepath">Base path</label>
                                <input type="text" class="form-control" id="config_basepath"
                                       value="{{ config_basepath }}" disabled>
                            </div>
                            {{ csrf|raw }}
                        </form>
                    </div>

                    <!-- Users tab -->
                    <div class="tab-pane container" id="users">
                        <h4>Users</h4>
                        <div class="table-responsive">
                            <table class="table table-condensed table-striped">
                                <caption>User(s) list</caption>
                                <thead>
                                <tr>
                                    <th>Username</th>
                                    <th>Email</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                {% for user in users %}
                                    <tr>
                                        <td>{{ user.username() }}</td>
                                        <td>{{ user.email() }}</td>
                                        <td></td>
                                    </tr>
                                {% endfor %}
                            </table>
                        </div>

                        <hr>

                        <h4>Add user</h4>

                        <form action="{{ url_for('adduser') }}" method="post" data-toggle="validator">
                            <div class="mb-3">
                                <label class="form-label" for="inputUsername">Username</label>
                                <input class="form-control" name="username" type="text" id="inputUsername"
                                       placeholder="username" aria-describedby="username_helpblock" required>
                            </div>

                            <div class="mb-3">
                                <label class="form-label" for="inputEmail">Email</label>
                                <input class="form-control" name="email" value="" type="email" id="inputEmail"
                                       placeholder="email address" data-error="Invalid email address" required>
                                <div class="help-block with-errors"></div>
                            </div>

                            <div class="mb-3">
                                <label class="form-label" for="password">Password</label>
                                <input class="form-control" name="password" type="password" id="password"
                                       placeholder="password" data-minlength="8" required>
                            </div>

                            <div class="mb-3">
                                <input class="form-control" name="confirmPassword" type="password" id="confirmPassword"
                                       placeholder="Confirm password" data-minlength="8" required>
                                <div class="form-text">Password must be at least 8 characters</div>
                            </div>

                            <button class="btn btn-sm btn-primary pull-right" type="submit">Create</button>
                            {{ csrf|raw }}
                        </form>

                    </div>

                </div>

                <div class="clearfix"></div>
            </div>

        </div>
    </div>
{% endblock %}